package com.dal.gm_api.util;

/**
 * @author : DengYing
 * @CreateDate : 2017年7月28日 下午5:44:31
 * @Description ：逻辑异常工具类
 */
public class GMError {

	public static GMException newLogicError(final int errorCode) {
		return new GMException(errorCode);
	}

	public static GMException newLogicError(final int errorCode, final String message) {
		return new GMException(errorCode, message);
	}

	public static void isAndTrue(final int errorCode, final String message, final boolean... expression) {
		boolean bool = true;
		for (boolean b : expression) {
			bool&=b;
		}
		if (bool) {
			throw newLogicError(errorCode, message);
		}
	}

	public static void isAndTrue(final int errorCode, final boolean... expression) {
		boolean bool = true;
		for (boolean b : expression) {
			bool&=b;
		}
		if (bool) {
			throw newLogicError(errorCode);
		}
	}

	public static void isOrTrue(final int errorCode, final String message, final boolean... expression) {
		boolean bool = true;
		for (boolean b : expression) {
			bool|=b;
		}
		if (bool) {
			throw newLogicError(errorCode);
		}
	}

	public static void isOrTrue(final int errorCode, final boolean... expression) {
		boolean bool = true;
		for (boolean b : expression) {
			bool|=b;
		}
		if (bool) {
			throw newLogicError(errorCode);
		}
	}
}
